#include <bits/stdc++.h>

using namespace std;

const int MAXN = 2e5+10;

char s[MAXN];
int rk[MAXN<<1],ork[MAXN<<1],n,id[MAXN],cnt[MAXN],px[MAXN],m,sa[MAXN];

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	scanf("%s",s+1); n = strlen(s+1);
	for(int i = 1;i <= n;i++) s[i+n] = s[i];
	n <<= 1; m = 300;
	for(int i = 1;i <= n;i++) cnt[rk[i] = s[i]]++;
	for(int i = 1;i <= m;i++) cnt[i] += cnt[i-1];
	for(int i = n;i >= 1;i--) sa[cnt[rk[i]]--] = i;
	for(int h = 1,p;h < n;h <<= 1,m = p){
 		p = 0;for(int i = n;i > n-h;i--) id[++p] = i;
		for(int i = 1;i <= n;i++) if(sa[i] > h) id[++p] = sa[i] - h;
		for(int i = 1;i <= m;i++) cnt[i] = 0;
		for(int i = 1;i <= n;i++) cnt[px[i] = rk[id[i]]]++;
		for(int i = 1;i <= m;i++) cnt[i] += cnt[i-1];
		for(int i = n;i >= 1;i--) sa[cnt[px[i]]--] = id[i];
		for(int i = 1;i <= n;i++) ork[i] = rk[i];
		p = 0;
		for(int i = 1;i <= n;i++)
			if(ork[sa[i]] == ork[sa[i-1]] && ork[sa[i]+h] == ork[sa[i-1] + h]) rk[sa[i]] = p;
			else rk[sa[i]] = ++p;
	}
	for(int i = 1;i <= n;i++) if(sa[i] <= (n>>1)) printf("%c",s[sa[i]+(n>>1)-1]); puts("");
	return 0;
}

